package com.xx.java8.chapter2;

import com.xx.java8.domain.Apple;
import com.xx.java8.utils.CollectionUtils;

import java.util.List;

public class App {
    public static void main(String[] args) {
        List<Apple> apples = CollectionUtils.initAppleList();
        CollectionUtils.appleListFormatted(apples, new AppleFancyFormatter());
        CollectionUtils.appleListFormatted(apples, new AppleSimpleFormatter());
        CollectionUtils.appleListFormatted(apples, a -> a.getColor().getName());

        //匿名类
        CollectionUtils.appleListFormatted(apples, new AppleFormatter() {
            @Override
            public String accept(Apple apple) {
                return apple.getWeight().toString();
            }
        });
    }
}
